

<extend name="Public:base" />
<block name="content">

	<div class="row">
		<div class="col-lg-12">
			<h1 class="page-header">新建用户</h1>
		</div>
		<!-- /.col-lg-12 -->
	</div>
	<!-- /.row -->
	<form id="add-form" class="form-horizontal" action="" method="post"
	enctype="multipart/form-data">
		<div class="form-group">
			<label class="col-md-2 control-label" for="real_name">真实姓名</label>
			<div class="col-md-6">
				<input type="text" class="form-control" placeholder="真实姓名" name="real_name" id="real_name" />
				<span id="real_name-help-block" class="help-block"></span>
			</div>
		</div>
		<div class="form-group">
			<label class="col-md-2 control-label" for="idno">身份证</label>
			<div class="col-md-6">
				<input type="text" class="form-control" placeholder="身份证" name="idno" id="idno" />
				<span id="idno-help-block" class="help-block"></span>
			</div>
		</div>
		<div class="form-group">
			<label class="col-md-2 control-label" for="mobile">手机</label>
			<div class="col-md-6">
				<input type="text" class="form-control" placeholder="手机" name="mobile" id="mobile" />
				<span id="mobile-help-block" class="help-block"></span>
			</div>
		</div>
		<div class="form-group">
			<label class="col-md-2 control-label" for="mobile2">手机2</label>
			<div class="col-md-6">
				<input type="text" class="form-control" placeholder="手机2" name="mobile2" id="mobile2" />
				<span id="mobile2-help-block" class="help-block"></span>
			</div>
		</div>
		<div class="form-group">
			<label class="col-md-2 control-label" for="address">住址</label>
			<div class="col-md-6">
				<input type="text" class="form-control" placeholder="住址" name="address" id="address"  />
				<span id="address-help-block" class="help-block"></span>
			</div>
		</div>
		<div class="form-group">
			<label class="col-md-2 control-label" for="content">备注</label>
			<div class="col-md-6">
				<textarea class="form-control" placeholder="备注" name="content" id="content" rows="3"></textarea>
			</div>
		</div>
		<div class="form-group">
			<label class="col-md-2 control-label" for="customer_type">用户类型</label>
			<div class="col-md-6">
				<label class="radio-inline">
					<input type="radio" name="customer_type" id="customer_type1" value="0" checked>个人客户</label>
				<label class="radio-inline">
					<input type="radio" name="customer_type" id="customer_type2" value="1">企业客户</label>
			</div>
		</div>
		
		<div class="form-group">
			<div class="col-md-2 col-md-offset-2">
            	<button id="submit" type="submit" class="btn btn-primary">Submit</button>
			</div>
		</div>
	</form>
</block>
<block name="extend-js">
<script>


	$(document)
	    	.ajaxStart(function(){
	    		$("button:submit").addClass("disabled").attr("disabled", true);
	    	})
	    	$(document).ajaxStop(function(){
	    		$("button:submit").removeClass("disabled").attr("disabled", false);
	    	});


    	$("form").submit(function(){
    		var self = $(this);
    		$.post(self.attr("action"), self.serialize(), success);
    		return false;

    		function success(data){
    			if (data.status) {
    				window.location.href=data.url;
    			} else{
    				$('.help-block').html('');
					if (data.real_name) {$('#real_name-help-block').html(data.real_name);};
					if (data.idno) {$('#idno-help-block').html(data.idno);};
					if (data.mobile) {$('#mobile-help-block').html(data.mobile);};
					if (data.mobile2) {$('#mobile2-help-block').html(data.mobile2);};
					if (data.address) {$('#address-help-block').html(data.address);};

    			};
    		}
    	});
</script>
</block>
